extends Node2D


# Declare member variables here. Examples:
# var a = 2
# var b = "text"

onready var MAIN = find_parent("MAIN")

# Called when the node enters the scene tree for the first time.
func _ready():
	$"PanelContainer/VBoxContainer/HBoxContainer/register".connect("pressed",self,"on_register")
	$"PanelContainer/VBoxContainer/HBoxContainer/back".connect("pressed",self,"on_back")
	pass # Replace with function body.

func on_register():
	var homeserver = $"PanelContainer/VBoxContainer/homeserver/edit".text
	var username = $"PanelContainer/VBoxContainer/username/edit".text
	var password = $"PanelContainer/VBoxContainer/password/edit".text
	MAIN.client.reset()
	MAIN.client.init_client(homeserver,username)
	var result = MAIN.client.register(password)
	if result:
		$"PanelContainer/VBoxContainer/done".visible = true
		$"PanelContainer/VBoxContainer/error".visible = false
	else:
		$"PanelContainer/VBoxContainer/done".visible = false
		$"PanelContainer/VBoxContainer/error".visible = true

func on_back():
	get_parent().activate()

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass
